<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <!--<div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="资产编号">
              <a-input placeholder="请输入资产编号" v-model="queryParam.propertyId"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>-->
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <!--<div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('biz_auction_enroll')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>-->

    <!-- table区域-begin -->
    <div>
      <!--<div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        :columns="columns"
        :dataSource="dataSource"
        :loading="loading"
        :pagination="ipagination"
        :scroll="{x:true}"
        @change="handleTableChange"
        bordered
        class="j-table-force-nowrap"
        ref="table"
        rowKey="id"
        size="middle">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="result" slot-scope="text,record">
          <div v-if="record.auditState==-1" style="color:#eb2f96;">未通过</div>
          <div v-else-if="record.auditState==0" style="color: #50bfff">待审核</div>
          <div v-else-if="record.auditState==1" style="color: #00DB00">已通过</div>
          <div v-else-if="record.auditState==2" style="color: #0063db">已充值</div>
          <div v-else-if="record.auditState==3" style="color: #aa3af8">已提现</div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span style="font-size: 12px;font-style: italic;" v-if="!text">无图片</span>
          <img :src="getImgView(text)" alt="" height="25px" style="max-width:80px;font-size: 12px;font-style: italic;" v-else/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span style="font-size: 12px;font-style: italic;" v-if="!text">无文件</span>
          <a-button
            :ghost="true"
            @click="downloadFile(text)"
            icon="download"
            size="small"
            type="primary"
            v-else>
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <span v-has="'customer_manager'" v-if="record.auditState==0 || record.auditState==null">
            <a-popconfirm  title="操作">

              <a slot="cancelText" @click="setRegistrationValid(record.id,0)">驳回</a>
              <a slot="okText" @click="setRegistrationValid(record.id,1)">通过</a>
              <a>审核</a>
            </a-popconfirm>

<!--            <a-divider type="vertical" />-->
          </span>
          <span v-has="'customer_manager'" v-if="record.auditState==1">
            <a @click="handleCharge(record)">充值</a>
<!--            <a-divider type="vertical" />-->
          </span>
          <span v-has="'customer_manager'" v-if="record.auditState==2">
            <a @click="handleTixian(record)">提现</a>

          </span>


          <!--<a-divider type="vertical" />-->
          <!--<a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>-->
        </span>

      </a-table>
    </div>

    <auction-enroll-modal @ok="modalFormOk" ref="modalForm"></auction-enroll-modal>
    <CustomerChargeModal  @ok="modalFormOk" ref="CustomerChargeModal"></CustomerChargeModal>
    <CustomerTixianModal  @ok="modalFormOk" ref="CustomerTixianModal"></CustomerTixianModal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin1'
  import AuctionEnrollModal from './modules/AuctionEnrollModal'
  import CustomerTixianModal from '@/views/customerlist/modules/CustomerTixianModal'
  import { getAction,postAction,putAction} from '@/api/manage'
  import CustomerChargeModal from '@/views/customerlist/modules/CustomerChargeModal'
  export default {
    name: 'AuctionEnrollList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      AuctionEnrollModal,
      CustomerChargeModal,
      CustomerTixianModal
    },
    data () {
      return {
        description: 'biz_auction_enroll管理页面',
        record:{},
        id:'',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          /*{
            title:'资产',
            align:"center",
            dataIndex: 'propertyId'
          },
          {
            title:'客户',
            align:"center",
            dataIndex: 'customerId'
          },
          {
            title:'是否有效',
            align:"center",
            dataIndex: 'result'
          },
          {
            title:'审核人',
            align:"center",
            dataIndex: 'auditorId'
          },
          {
            title:'审核状态[0:未通过,1:已通过,2:待审核]',
            align:"center",
            dataIndex: 'auditState'
          },
          {
            title:'审核意见',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'创建人',
            align:"center",
            dataIndex: 'createBy'
          },

          {
            title:'修改人',
            align:"center",
            dataIndex: 'updateBy'
          },
          {
            title:'修改时间',
            align:"center",
            dataIndex: 'updateTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'是否删除',
            align:"center",
            dataIndex: 'delFlag'
          },*/
          {
            title:'公司名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title:'联系人',
            align:"center",
            dataIndex: 'contactsName'
          },
          /*{
            title:'企业名称',
            align:"center",
            dataIndex: 'contactsName'
          },*/
          {
            title:'联系人电话',
            align:"center",
            dataIndex: 'contactsPhone'
          },
          /*{
            title:'保证金',
            align:"center",
            dataIndex: 'earnestMoney',
            customRender:function (text) {
              return text+'元'
            }
          },*/
          {
            title:'身份证号码',
            align:"center",
            dataIndex: 'idNo'
          },
          {
            title:'报名时间',
            align:"center",
            dataIndex: 'createTime',
            /*customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }*/
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'result',
            scopedSlots: { customRender: 'result' }
          },
          /*{
            title:'联系地址',
            align:"center",
            dataIndex: 'contactsAddress'
          },
          {
            title:'是否胜出者',
            align:"center",
            dataIndex: 'isWinner'
          },
          {
            title:'完成时间',
            align:"center",
            dataIndex: 'finishTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },*/
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            // fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/auctionEnroll/list",
          delete: "/auctionEnroll/delete",
          deleteBatch: "/auctionEnroll/deleteBatch",
          exportXlsUrl: "/auctionEnroll/exportXls",
          importExcelUrl: "auctionEnroll/importExcel",
          setRegistrationValid: "/auctionEnroll/setRegistrationValid",
          WithdrawalPage:"/customer/WithdrawalPage/",//提现
          rechargePage:"/customer/rechargePage/"//充值
        },
        dictOptions:{},
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      //核实结果
      setRegistrationValid(id,state){
        putAction(this.url.setRegistrationValid,{id:id,state:state}).then((res)=>{
          console.log(res)
          this.searchQuery()
        })
      },
      setRegistrationValid1(id){
        console.log(id)
      },
      //充值
      handleCharge(record){
        // console.log('record.customerId',record.customerId)
        console.log('record',record)
        this.loading = true
        getAction(this.url.rechargePage+record.customerId+'/'+record.propertyId).then((res)=>{
          console.log('充值res',res)
          if (res.success){
            this.loading = false
            let record1 = Object.assign(record,res.result)
            console.log('record1',record1)
            this.$refs.CustomerChargeModal.edit(record1);
            this.$refs.CustomerChargeModal.title = "充值";
            this.$refs.CustomerChargeModal.disableSubmit = true;
          }else {
            this.$message.error(res.message)
          }
        })
      },



      //提现
      handleTixian(record){
        console.log('record.customerId',record.customerId)
        this.loading = true
        getAction(this.url.WithdrawalPage+record.customerId+'/'+record.propertyId).then((res)=>{
          console.log('res',res)
          if (res.success){
            this.loading = false
            let record1 = Object.assign(record,res.result)
            console.log('record1',record1)
            this.$refs.CustomerTixianModal.edit(record1);
            this.$refs.CustomerTixianModal.title = "提现";
            this.$refs.CustomerTixianModal.disableSubmit = true;
          }else {
            this.$message.error(res.message)
            this.loading = false
          }
        })
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';

  .btnbtn{
    /*color: #eb2f96 !important;*/
  }

</style>